function addLog(message, type = 'info', options = {}) {
    class LogItem {
        constructor(message, type, options) {
            this.time = new Date().toLocaleString();
            this.message = message;
            this.type = type;
            this.options = options;
        }
    }

    const logItem = new LogItem(message, type, options);
    // 由于 Node.js 没有 document 对象，这里简单打印日志
    if (typeof document === 'undefined') {
        if (type === 'error') {
            console.error(`[${logItem.time}] [${logItem.type}] ${logItem.message}`);
        } else {
            console.log(`[${logItem.time}] [${logItem.type}] ${logItem.message}`);
        }
        return;
    }

    const logElement = document.createElement('div');
    logElement.textContent = `${logItem.time} - ${logItem.message}`;

    if (type === 'error') {
        const errorLogs = document.getElementById('errorLogs');
        if (errorLogs) {
            errorLogs.appendChild(logElement);
            errorLogs.scrollTop = errorLogs.scrollHeight;
        }
    } else {
        const processLogs = document.getElementById('processLogs');
        if (processLogs) {
            processLogs.appendChild(logElement);
            processLogs.scrollTop = processLogs.scrollHeight;
        }
    }
}

window.addLog = addLog;
